<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<!-- jquery和ui -->
<script type="text/javascript" src="lib/jquery_lastest.js"></script>
<script type="text/javascript" src="lib/jquery_timers_lastest.js"></script>

<script type="text/javascript">
	$(function() {
	//https://www.google.com/latitude/apps/badge/api?user=5661037576488719294&type=json
	//	var user="5661037576488719294";
	//	$.getJSON("jsonproxy.asp",{"url":"https://www.google.com/latitude/apps/badge/api?user="+user+"&type=json"},function(data){
	//		lng=data.features[0].geometry.coordinates[0];
	//		lat=data.features[0].geometry.coordinates[1];
	//		id=data.features[0].properties.id;
	//		timeStamp=data.features[0].properties.timeStamp;
	//		accuracyInMeters=data.features[0].properties.accuracyInMeters;
	//		reverseGeocode=data.features[0].properties.reverseGeocode;
			//alert(lat);
			//alert(lng);
			//alert(id);
			//alert(timeStamp);
			//alert(accuracyInMeters);
			//alert(reverseGeocode);
			//var t = new Date(timeStamp);
			//alert(t.toLocaleString());

	//		$("#res").html(reverseGeocode);
	//	});
function closeWindow() {  
    window.opener = null;  
    window.open('', '_self', '');  
    window.close();  
} 	
	
		$("body").everyTime('10s','A',function(){
			$(".cl_usergeo").each(function(){
				var current=$(this);
				var user=current.text();
						$("#info").html("正在更新"+user);
				//		current.html(user+"正在更新");
				//alert(user);
				
					//	$.getJSON("jsonproxy.asp",{"url":"https://www.google.com/latitude/apps/badge/api?user="+user+"&type=json"},function(data){
				$.ajax({
					type: "GET",
					async: false,
					url: "jsonproxy.asp",
					data: {"url":"https://www.google.com/latitude/apps/badge/api?user="+user+"&type=json"},
					success: function(data){
						 //alert( "Data Saved: " + msg );
						if(!$.isEmptyObject(data.features)){
							id=data.features[0].properties.id;
							lat=data.features[0].geometry.coordinates[1];
							lng=data.features[0].geometry.coordinates[0];
							timeStamp=data.features[0].properties.timeStamp;
							accuracyInMeters=data.features[0].properties.accuracyInMeters;
							reverseGeocode=data.features[0].properties.reverseGeocode;
							//alert(lat);
							//alert(lng);
							//alert(id);
							//alert(timeStamp);
							//alert(accuracyInMeters);
							//alert(reverseGeocode);
							//var t = new Date(timeStamp);
							//alert(t.toLocaleString());

							current.next().text(reverseGeocode+" "+lat+" "+lng+" "+timeStamp+" "+accuracyInMeters);
							$.getJSON("update_usergeo.asp",{"usergeo_user":id,"usergeo_lat":lat,"usergeo_lng":lng,"usergeo_timestamp":timeStamp,"usergeo_inmeters":accuracyInMeters,"usergeo_reverse":reverseGeocode},function(data){});
						}else{
							current.next().text("定位已关闭！");
						}			
					}
			
				});
			});
			$("#info").html("更新完成");
			$("body").everyTime('10s','B',function(){
				closeWindow();
			},1,true);
		},1,true);
	});
</script>

</head>
<body>
<div id="info"></div>
<%
set rs = Server.CreateObject("ADODB.Recordset")
sql="SELECT cl_usergeo FROM cl where cl_usergeo<>'' and cl_usergeo is not null"
rs.open sql,conn,1,1
'response.write(sql)
do while not rs.eof
%>
<div>
	<span class="cl_usergeo"><%=rs("cl_usergeo")%></span><span></span>
</div>
<%	
	rs.movenext
loop
	
rs.close
conn.close
set conn=nothing

%>


</body>
</html>
